package com.yx.common.core.config;



import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

/**
 * TODO 类作用描述
 *
 * @author sbl

 */
@Configuration
public class JacksonConfig {

    @Value("${spring.jackson.date-format}")
    private String dateFormat;

    @Value("${spring.jackson.time-zone}")
    private String timeZone;

    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();

        // 设置日期格式
        objectMapper.setDateFormat(new SimpleDateFormat(dateFormat));

        // 设置时区
        objectMapper.setTimeZone(TimeZone.getTimeZone(timeZone));

        return objectMapper;
    }
}

